#============================================================
#    Log
#============================================================
# - datetime: 2022-09-07 19:35:12
#============================================================

class_name Log


static func info(params, sep:=" "):
	if params is Array:
		print(_format_str(params, sep))
	else:
		print(_format_str([params], sep))


static func err(params, sep:=" "):
	if params is Array:
		printerr(_format_str(params, sep))
	else:
		printerr(_format_str([params], sep))


static func _format_str(params: Array, sep: String) -> String:
	if get_stack().size() == 0:
		return sep.join(params)
	var stack : Dictionary = get_stack()[2]
	var head := "%-60s" % [
		"{line}: {function} | {source}".format({
			"function": stack['function'],
			"line": stack['line'],
			"source": stack['source'].get_file(),
		}),
	]
	return "%s | %s" % [head , sep.join(params)]
